package com.hnevc.vx.adapter;

import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.content.Context;
import android.widget.ImageView;
import android.widget.TextView;
import com.hnevc.vx.R;
import com.hnevc.vx.bean.LianxXiren;
import java.util.List;


public class MyAdapater2 extends BaseAdapter {
    Context context;
    private List<LianxXiren.ResultBean> lianbxirenList;
     String TAG = "test";
    public MyAdapater2(Context context, List<LianxXiren.ResultBean> lianbxirenList) {
        this.context = context;
        this.lianbxirenList = lianbxirenList;
    }

    @Override
    public int getCount() {
        return lianbxirenList.size();
    }

    @Override
    public Object getItem(int position) {
        return lianbxirenList.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        convertView = View.inflate(context, R.layout.item_fragment1,null);
        TextView textView1 = convertView.findViewById(R.id.item_nc_tv);
        TextView textView2 = convertView.findViewById(R.id.item_xx_tv);
        TextView textView3 = convertView.findViewById(R.id.item_sj_tv);
        ImageView imageView = convertView.findViewById(R.id.item1_iv);
        textView1.setText(lianbxirenList.get(position).getName()+"");
        textView2.setText(lianbxirenList.get(position).getXiaoxi()+"");
        textView3.setText(lianbxirenList.get(position).getTime()+"");
        String url = lianbxirenList.get(position).getUrl();
        int imgid = context.getResources().getIdentifier(url,"drawable",context.getPackageName());
        Log.e(TAG, "getView: " +url );
        Log.e(TAG, "getView: " +imgid );
        imageView.setImageResource(imgid);
        return convertView;
    }
}
